home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / FREOPEN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  548 b   |  18 lines

  1. /*  freopen.c, from p. 430 of Turbo C Bible  */
  2. #include <stdio.h>
  3. main()
  4. {
  5.     char filename[81];
  6.     printf("enter file name where output sould go: ");
  7.     gets(filename);
  8.     printf("If all goes well, use TYPE %s to see \ result.\n", filename);
  9.                 /*  Redirect stdout to this file  */
  10.     if (freopen(filename, "w", stdout) == NULL)
  11.     {
  12.     printf("freopen failed.\n");
  13.     exit(0);
  14.     }
  15.                 /*  Print some lines  */
  16.     printf("Redirexting stdout to the file %s\n", filename);
  17.     printf("All output will be in this file.\n");
  18. }